import json
import inspect

path = r'E:\TestCaseProject\pythonProject_BuildTestCase\func_callback\func_import\add.py'
module_name:str = path.split('\\')[-1].split('.')[0]

argspec = inspect.getfullargspec(add)
print(argspec.args, argspec.defaults, type(argspec.args))         # 生成json文件
d:dict = {}
for i in range(len(argspec.args)):
    key = argspec.args[i]
    value = argspec.defaults[i]
    d[key] = value
print(d)
with open(f'{module_name}.json', 'w') as f:
    json.dump(d, f, indent=4, ensure_ascii=False)

res = add(num1=d['num1'], num2=d['num2'])
print(res)
# from func_imp.add import add
# exec ('from add import *')
#
# print(add(1,2))
# print(a)